home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 1_2002.ISO / Data / Zips / String Man2984110192001.psc / Encrypt / Form1.frm (.txt) next >
Encoding:
Visual Basic Form  |  2001-10-19  |  2.3 KB  |  68 lines

  1. VERSION 5.00
  2. Begin VB.Form Form1 
  3.    Caption         =   "Form1"
  4.    ClientHeight    =   6210
  5.    ClientLeft      =   60
  6.    ClientTop       =   345
  7.    ClientWidth     =   7890
  8.    LinkTopic       =   "Form1"
  9.    ScaleHeight     =   6210
  10.    ScaleWidth      =   7890
  11.    StartUpPosition =   3  'Windows Default
  12.    Begin VB.CommandButton Command1 
  13.       Caption         =   "ENCRYPT/DECRYPT"
  14.       Height          =   975
  15.       Left            =   2400
  16.       TabIndex        =   1
  17.       Top             =   4800
  18.       Width           =   3135
  19.    End
  20.    Begin VB.TextBox Text1 
  21.       Height          =   3855
  22.       Left            =   240
  23.       MultiLine       =   -1  'True
  24.       TabIndex        =   0
  25.       Text            =   "Form1.frx":0000
  26.       Top             =   480
  27.       Width           =   7215
  28.    End
  29. Attribute VB_Name = "Form1"
  30. Attribute VB_GlobalNameSpace = False
  31. Attribute VB_Creatable = False
  32. Attribute VB_PredeclaredId = True
  33. Attribute VB_Exposed = False
  34. Private Sub Command1_Click()
  35.     Dim i As Double
  36.     Dim Char As String
  37.     Dim NewStr As String
  38.     For i = 1 To Len(Text1)
  39.         Char = Chr(Asc(Mid(Text1, i, 1)) Xor 17.7447446868468)
  40.         NewStr = NewStr & Char
  41.     Next
  42.     Text1 = NewStr
  43. End Sub
  44. 'This code is very basic. First we have the For/Next loop going through
  45. 'each character in the Text1 control. Then to narrow down the next part
  46. 'to make it simpler for you it would look like this
  47. 'Char = Mid(Text, i, 1)
  48. 'Char = Asc(Char)
  49. 'Char = Char Xor 17.7447446868468)
  50. 'Char = Chr(Char)
  51. 'The first line is getting the next character to encrypt.
  52. 'next it is converting that character to ascii
  53. 'then using the Xor operator to mix it around a bit
  54. 'now converting it back to a charcter.
  55. 'The Xor function is good because it doesn't need a seperate routine
  56. 'to decrpyt.
  57. 'You can mix it around a bit if you like, try changing the
  58. '"Xor 17.7447446868468" to "+ 1" this will make it use the next
  59. 'letter in the alphabet for each character. using - 1 will
  60. 'use the previous letter for each character. If you use + or -
  61. 'instead of Xor you will need a decrypt function that does the opposite.
  62. 'Example
  63. 'To Encrypt use
  64. 'Char = Chr(Asc(Mid(Text1, i, 1)) + 1)
  65. 'To Decrypt use
  66. 'Char = Chr(Asc(Mid(Text1, i, 1)) - 1)
  67. 'Thanks for reading my tutorial, therefore visiting my site.
  68.